package GUIMain;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JMenuBar;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.MouseEvent;
import java.awt.Color;
import javax.swing.JMenuItem;
import javax.swing.JTabbedPane;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.factories.FormFactory;
import com.jgoodies.forms.layout.RowSpec;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.JLabel;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.GridLayout;
import javax.swing.JTextField;
import java.awt.FlowLayout;
import javax.swing.JInternalFrame;
import javax.swing.JSplitPane;
import javax.swing.BoxLayout;
import javax.swing.SwingConstants;
import java.awt.Font;
import javax.swing.JButton;
import javax.swing.JSeparator;
import javax.swing.UIManager;
import java.awt.SystemColor;
import com.jgoodies.forms.factories.DefaultComponentFactory;

import data.FilePath;
import data.Reference;

import javax.swing.JCheckBox;
import java.awt.event.MouseAdapter;
import javax.swing.JProgressBar;

public class HomeGUI {

	private JFrame frame;
	public static String REPORT_CONFIG_PATH = "Data/DEFAULT";
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					HomeGUI window = new HomeGUI();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public HomeGUI() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		
		frame = new JFrame();
		frame.setBounds(100, 100, 401, 372);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		
		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		tabbedPane.setBounds(0, 0, 383, 324);
		frame.getContentPane().add(tabbedPane);
		
		JPanel Homepage = new JPanel();
		tabbedPane.addTab("Home", null, Homepage, null);
		Homepage.setLayout(null);
		
		JLabel lblWelcomeToReport = new JLabel("Welcome to Report Generator!");
		lblWelcomeToReport.setFont(new Font("Tahoma", Font.PLAIN, 16));
		lblWelcomeToReport.setVerticalAlignment(SwingConstants.TOP);
		lblWelcomeToReport.setBounds(12, 32, 338, 30);
		Homepage.add(lblWelcomeToReport);
		
		JLabel lblChangeDefaultSetting = new JLabel("TOPOL Document Generator:");
		lblChangeDefaultSetting.setBounds(21, 90, 225, 30);
		Homepage.add(lblChangeDefaultSetting);
		
		JButton topolButton = new JButton("Open");
		topolButton.setBounds(250, 90, 80, 26);
		Homepage.add(topolButton);
		
		JLabel lblWbiDocumentGenerator = new JLabel("WBi Document Generator:");
		lblWbiDocumentGenerator.setBounds(21, 130, 225, 30);
		Homepage.add(lblWbiDocumentGenerator);
		
		JButton wbiButton = new JButton("Open");

		wbiButton.setBounds(250, 130, 80, 26);
		Homepage.add(wbiButton);
		
		JLabel lblUnschedulePoReport = new JLabel("Late PO Report Generator:");
		lblUnschedulePoReport.setBounds(21, 170, 225, 30);
		Homepage.add(lblUnschedulePoReport);
		
		JButton latepoButton = new JButton("Open");
		latepoButton.setBounds(250, 170, 80, 26);
		Homepage.add(latepoButton);
		
		JLabel lblContractCheckingReport = new JLabel("Contract Checking Report Generator:");
		lblContractCheckingReport.setBounds(21, 210, 225, 30);
		Homepage.add(lblContractCheckingReport);
		
		JButton contractButton = new JButton("Open");
		contractButton.setBounds(250, 210, 80, 26);
		Homepage.add(contractButton);
		
		
		
		topolButton.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				REPORT_CONFIG_PATH = "Data/TOPOL/";
				Reference.reportNo = 1;
				Reference.reportGenerator = "TOPOL Document Generator:";
				GUILoader.initialize();
			}
		});
		wbiButton.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				REPORT_CONFIG_PATH = "Data/WBi/";
				Reference.reportNo = 2;
				Reference.reportGenerator = "WBi Document Generator:";
				GUILoader.initialize();
			}
		});
		latepoButton.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				REPORT_CONFIG_PATH = "Data/LatePO/";
				Reference.reportNo = 3;
				Reference.reportGenerator = "Late PO Report Generator:";
				GUILoader.initialize();
			}
		});
		contractButton.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				REPORT_CONFIG_PATH = "Data/Contract/";
				Reference.reportNo = 4;
				Reference.reportGenerator = "Contract Type Checking Generator:";
				GUILoader.initialize();
			}
		});
	}
}
